<?php
    $query="SELECT * FROM Klient";
    $wynik=mysql_query($query) or die('zapytanie niudane: '.mysql_error());
    
    echo "<form action=\"skrypty/peln/akcje/wyswietlPeln.php?login=$login\" method=\"post\">";
    echo "<select name=\"klient\">";
        while($line = mysql_fetch_array($wynik, MYSQL_NUM))
            echo "<option value=\"$line[0]\">$line[1] $line[2]</option>";
    echo "</select>";
    echo "<input type=\"submit\" name=\"wyswielt\" value=\"Wyświetl\">";
    echo "</form>";
        
    if ($opcja=="wyswietl"){
        $query="SELECT * FROM Klient where idKlienta=$idKlienta";
		$wynik=mysql_query($query) or die('zapytanie niudane: '.mysql_error());
		echo "<table><tr>
				<td>Imie</td>
				<td>Nazwisko</td>
				<td>Adres</td>
				<td>Telefon</td>
				<td>Fax</td>
				<td>WWW</td>
				<td>email</td>
				<td>REGON</td>
                <td>NIP</td>
                <td>Firma</td>
			</tr>";

		while($line = mysql_fetch_array($wynik, MYSQL_ASSOC)){
			echo "<tr>";
            $flaga=true;
            $num=0;
			foreach($line as $col){
                if($flaga) $flaga=false;
                
                else{
                    echo "<td>$col</td>";
                    $num++;
                }
            }

            echo "</tr>";
		}
		echo "</table>";
    $query="SELECT * FROM Pelnomocnictwo where idKlienta=$idKlienta";
	$wynik=mysql_query($query) or die('zapytanie niudane: '.mysql_error());
    echo "<form action=\"skrypty/peln/akcje/modUsPeln.php?login=$login\" method=\"post\">";
		echo "<table><tr>
				<td>Usuń</td>
                <td>Modyfikuj</td>
				<td>Opis</td>
			</tr>";

        while($line = mysql_fetch_array($wynik, MYSQL_NUM)){
            $adres = "skrypty/peln/form/podglPeln.php?id={$line[0]}";
			echo "<tr>";
                echo "<td><input type=checkbox name=\"{$line[0]}\"></td>\n";
                echo "<td><Input type=radio name=\"mod\" value=\"{$line[0]}\"></td>\n";
                echo "<td><a target=\"_blank\" href=\"$adres\"
                        onclick=\"window.open('$adres', '_blank', 'resizable=no,width=800,height=600').focus(); return false\">{$line[2]}</a></td>\n";
            echo "</tr>\n";
		}
		echo "</table>";
        echo "<input type=submit name=\"usun\" id=\"usun\" value=\"usuń\"> | ";
        echo "<input type=submit name=\"modyfikuj\" id=\"modyfikuj\" value=\"modyfikuj\">";
        echo "</form>";   
    }
?>

